package com.netty.esc.service.http.impl;

import com.netty.esc.Interceptor.annotation.FuckAll;
import com.netty.esc.dao.mapper.UserRoleMapper;
import com.netty.esc.entity.model.UserInfoDTO;
import com.netty.esc.entity.pojo.UserRole;
import com.netty.esc.service.http.UserRoleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@FuckAll
public class UserRoleImpl implements UserRoleService {

    @Resource
    UserRoleMapper userRoleMapper;

    @Override
    public UserRole getUserRole(UserInfoDTO userInfoDTO) {
        final Long userInfoDTOId = userInfoDTO.getId();
        final List<String> userRolesById = userRoleMapper.findUserRolesById(userInfoDTOId);
        final List<String> userPermissionsById = userRoleMapper.findUserPermissionsById(userInfoDTOId);
        UserRole userRole = new UserRole();
        userRole.setUserId(userInfoDTOId);
        userRole.setRoles(userRolesById);
        userRole.setPermissions(userPermissionsById);
        return userRole;
    }
}
